<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%-- <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%> --%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<head>
	<title><spring:message code="label.adminTitle"/></title>
</head>
<sec:authorize access="hasAnyRole('ROLE_USER', 'ROLE_ADMIN')">
<tiles:insertDefinition name="defaultTemplate">
	<tiles:putAttribute name="body">
		<div class="body">
			<div class="col-sm-10 col-md-10 ">
				<div class="panel panel-primary">
					<div class="panel-heading">
						<h3 class="panel-title"><spring:message code="label.adminPanelTitle"/></h3>
					</div>
					<!-- Table -->
					<div class="table-responsive">
					<table id="datatable"
						class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th></th>
								<th><input placeholder="<spring:message code="label.searchPlaceHolder"/>" class="form-control"
									type="text" id="searchuser" /></th>
								<th></th>
							</tr>
							<tr>
								<th>#</th>
								<th><spring:message code="label.user"/></th>
								<th><spring:message code="label.detail"/></th>
							</tr>
						</thead>
						<tbody>
							<c:forEach var="logList" items="${logList}">
								<tr>
									<td>1</td>
									<td>${logList.user.username}</td>
									<td>${logList.logDetail}</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
					</div>
				</div>
			</div>
		</div>


	</tiles:putAttribute>
</tiles:insertDefinition>
</sec:authorize>

<script>
	$(document).ready(function() {
		var table = $('#datatable').DataTable({
			responsive : true,
			"columnDefs" : [ {
				"width" : "3%",
				"targets" : 0
			}, {
				"width" : "10%",
				"targets" : 1
			} ]
		,
		//auto increase collumn
		"fnDrawCallback" : function(
				oSettings) {
			/* Need to redo the counters if filtered or sorted */
			if (oSettings.bSorted
					|| oSettings.bFiltered) {
				for (var i = 0, iLen = oSettings.aiDisplay.length; i < iLen; i++) {
					$(
							'td:eq(0)',
							oSettings.aoData[oSettings.aiDisplay[i]].nTr)
							.html(i + 1);
				}
			}
		},
		});

		$('#searchuser').on('keyup change', function() {
			table.columns(1).search(this.value).draw();
		});
	});
	$("#admin").addClass('active1'); // activated list-item
	$("#advanceSearch").hide();
</script>